public class School {
    // 私有属性
    private List<Department> departments;
    private List<Student> students;

    // 构造方法
    public School() {
        this.departments = new ArrayList<>();
        this.students = new ArrayList<>();
    }

    // 添加系的方法
    public void addDepartment(Department department) {
        departments.add(department);
    }

    // 添加学生的方法
    public void addStudent(Student student) {
        students.add(student);
    }

    // 获取所有系的方法
    public List<Department> getDepartments() {
        return departments;
    }

    // 获取所有学生的方法
    public List<Student> getStudents() {
        return students;
    }
}

public class Department {
    // 私有属性
    private String name;
    private List<Instructor> instructors;
    private List<Subject> subjects;

    // 构造方法
    public Department(String name) {
        this.name = name;
        this.instructors = new ArrayList<>();
        this.subjects = new ArrayList<>();
    }

    // 添加指导教师的方法
    public void addInstructor(Instructor instructor) {
        instructors.add(instructor);
    }

    // 添加课程的方法
    public void addSubject(Subject subject) {
        subjects.add(subject);
    }

    // 获取所有指导教师的方法
    public List<Instructor> getInstructors() {
        return instructors;
    }

    // 获取所有课程的方法
    public List<Subject> getSubjects() {
        return subjects;
    }

    // 获取系名称的方法
    public String getName() {
        return name;
    }
}

public class Instructor {
    // 私有属性
    private String name;
    private List<Course> courses;

    // 构造方法
    public Instructor(String name) {
        this.name = name;
        this.courses = new ArrayList<>();
    }

    // 添加课程的方法
    public void addCourse(Course course) {
        if (courses.size() < 3) {
            courses.add(course);
        } else {
            throw new IllegalArgumentException("Instructor can only teach up to 3 courses.");
        }
    }

    // 获取所有课程的方法
    public List<Course> getCourses() {
        return courses;
    }

    // 获取指导教师名称的方法
    public String getName() {
        return name;
    }
}

public class Student {
    // 私有属性
    private String name;
    private List<Course> courses;

    // 构造方法
    public Student(String name) {
        this.name = name;
        this.courses = new ArrayList<>();
    }

    // 添加课程的方法
    public void addCourse(Course course) {
        if (courses.size() < 5) {
            courses.add(course);
        } else {
            throw new IllegalArgumentException("Student can only take up to 5 courses.");
        }
    }

    // 获取所有课程的方法
    public List<Course> getCourses() {
        return courses;
    }

    // 获取学生名称的方法
    public String getName() {
        return name;
    }
}

public class Course {
    // 私有属性
    private String name;
    private Department department;
    private Instructor instructor;

    // 构造方法
    public Course(String name, Department department, Instructor instructor) {
        this.name = name;
        this.department = department;
        this.instructor = instructor;
    }

    // 获取课程名称的方法
    public String getName() {
        return name;
    }

    // 获取所属系的方法
    public Department getDepartment() {
        return department;
    }

    // 获取授课教师的方法
    public Instructor getInstructor() {
        return instructor;
    }
}

public class Subject {
    // 私有属性
    private String name;
    private Department department;

    // 构造方法
    public Subject(String name, Department department) {
        this.name = name;
        this.department = department;
    }

    // 获取课程名称的方法
    public String getName() {
        return name;
    }

    // 获取所属系的方法
    public Department getDepartment() {
        return department;
    }
}
